﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PhysioAssist2Win
{
    /// <summary>
    /// Interaction logic for Noticias.xaml
    /// </summary>
    public partial class Noticias : Window
    {
        public Noticias()
        {
            InitializeComponent();



            //Ajusta posição e tamanho das janelas
            double width = System.Windows.SystemParameters.PrimaryScreenWidth;
            double height = System.Windows.SystemParameters.PrimaryScreenHeight;

            winNoticias.Width = width;
            winNoticias.Height = height;

            winNoticias.Left = 0;
            winNoticias.Top = 0;



            //Larguras dos Paineis
            pnlEsq.Width = winNoticias.Width * 0.2;
            pnlEsq.Height = winNoticias.Height;
            pnlEsq.Margin = new Thickness(20, 20, 0, 0);

            pnlDir.Width = (winNoticias.Width - 60) * 0.8;
            pnlDir.Height = winNoticias.Height;
            pnlDir.Margin = new Thickness(20, 20, 0, 0);



            //Carrega Noticias
            CarregaNoticias();

        }




        private void CarregaNoticias()
        {

            WS.WSSoapClient client = new WS.WSSoapClient();
            WS.Noticia[] lst = client.ListaNoticias();


            foreach (WS.Noticia noti in lst)
            {

                Label lbl = new Label();
                TextBlock txt = new TextBlock();

                lbl = new Label(); txt = new TextBlock();
                txt.Text = noti.data.ToShortDateString() + " - " + noti.fonte;
                txt.TextWrapping = TextWrapping.Wrap;
                lbl.Content = txt;
                lbl.FontSize = 20;
                lbl.Foreground = Brushes.Gray;
                pnlDir.Children.Add(lbl);


                lbl = new Label(); txt = new TextBlock();
                txt.Text = noti.titulo;
                txt.TextWrapping = TextWrapping.Wrap;
                lbl.Content = txt;
                lbl.FontSize = 30;
                pnlDir.Children.Add(lbl);


                lbl = new Label(); txt = new TextBlock();
                lbl.Margin = new Thickness(0, 0, 0, 60);
                txt.Text = noti.conteudo;
                txt.TextWrapping = TextWrapping.Wrap;
                lbl.Content = txt;
                lbl.FontSize = 17;
                pnlDir.Children.Add(lbl);

            }



        }

        private void pnlEsq_MouseDown(object sender, MouseButtonEventArgs e)
        {
            winNoticias.Close();
        }

    }
}
